import { Controller, Get, Post, Body, Param, Put, Delete } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiProperty } from '@nestjs/swagger'

class CreatePostDto {
	@ApiProperty({
		description: '标题'
	})
	title: string
	@ApiProperty({
		description: '内容'
	})
	content: string
}

@Controller('posts')
@ApiTags('posts')
export class PostsController {
	@Get('/')
	@ApiOperation({
		summary: '博客列表'
	})
	index(){
		return ''
	}

	@Post()
	@ApiOperation({
		summary: '创建帖子'
	})
	create(@Body() body: CreatePostDto){
		console.log(body.title, body.content)
		return {
			success: true
		}
	}


	@Get('/:id')
	@ApiOperation({
		summary: '获取文章'
	})
	detail(@Param() param){
		console.log(param.id)
		return ''
	}

	@Put('/:id')
	@ApiOperation({
		summary: '更新'
	})
	update(@Param() param, @Body() body: CreatePostDto){
		console.log(param.id, body.title)
		return {
			success: true
		}
	}

	@Delete('/:id')
	@ApiOperation({
		summary: '删除'
	})
	remove(@Param() param){

		return {
			success: true
		}
	}

}
